package com.study.experiment05.bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


/**
 * @author WS
 */
public class UserChecker {
    private String userName;
    private String password;
    private DBConn conn;
    private String sql;

    public UserChecker() {

    }

    public UserChecker(String name, String passwd) {
        userName = name;
        password = passwd;
        conn = new DBConn();
        sql = "select * from tab_user where name = '" + userName + "'and pwd = '" + password + "'";
    }

    public boolean check() {
        Connection connection = conn.getConn();
        Statement st;
        ResultSet rs = null;
        try {
            st = connection.createStatement();
            rs = st.executeQuery(sql);
            if (rs.next()) {
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
}
